package com.yanqu.road.server.cmd.activity.union;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.UnionActivityConditionData;
import com.yanqu.road.pb.activity.union.UnionRechargeUserProto;
import com.yanqu.road.pb.crossunion.activity.CrossUnionActivityRankDataProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.server.manger.union.UnionActivityMgr;
import com.yanqu.road.server.pb.ActivityPb;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.server.command.Cmd;

@Cmd(code = Protocol.S_UNION_ACTIVITY_RECHARGE_USER,desc = "家族充值人数活动")
public class GetUnionChargeUserCmd extends AbstractCommand {

    private int activityId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        UnionRechargeUserProto.UnionRechargeUserReqMsg reqMsg = UnionRechargeUserProto.UnionRechargeUserReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData(GamePlayer player) {
        UnionRechargeUserProto.UnionRechargeUserRespMsg.Builder respMsg = UnionRechargeUserProto.UnionRechargeUserRespMsg.newBuilder();
        ActivityInfo activityInfo = NormalActivityMgr.getActivityInfo(activityId);
        if(activityInfo == null){
            ret = GameErrorCode.E_ACTIVITY_NO_FOUND;
        }else{
            CrossUnionActivityRankDataProto.CrossUnionRechargeDataReqMsg.Builder reqMsg = CrossUnionActivityRankDataProto.CrossUnionRechargeDataReqMsg.newBuilder();
            reqMsg.setActivityId(activityId);
            reqMsg.setUnionId(player.getUserInfo().getUnionUid());
            reqMsg.setMsgType(2);
            player.sendPacket(CrossProtocol.C_CROSS_UNION_RECHARGE_ACTIVITY_DATA, reqMsg);
            return;
        }
        respMsg.setRet(ret);
        player.sendPacket(Protocol.U_UNION_ACTIVITY_RECHARGE_USER, respMsg);
    }
}
